/**
 * 手机号验证
 * @param {val} 
 * */
const IsPhone = (val) => {
	const reg = /0?(13|14|15|17|18|19)[0-9]{9}/;
	return reg.test(val)
}

/**
 * 身份证验证
 * @param {val} 
 */
const IsIDCard = (val) => {
	const reg = /\d{17}[\d|x]|\d{15}/;
	return reg.test(val)
}

/**
 * email地址
 * @param {val}
 */
const IsEmail = (val) => {
	const reg = /\w[-\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\.)+[A-Za-z]{2,14}/;
	return reg.test(val)
}

/**
 * 整数
 * @param {val} 
 */
const IsInt = (val) => {
	const reg = /-?[1-9]\d*/
	return reg.test(val)
}

/**
 * 邮政编码
 * @param {val} 
 * */
const IsPostcard = (val) => {
	const reg = /\d{6}/;
	return reg.test(val)
}

export default {
	install(Vue) {
		Vue.prototype.$IsPhone = IsPhone,
		Vue.prototype.$IsIDCard = IsIDCard,
		Vue.prototype.$IsEmail = IsEmail,
		Vue.prototype.$IsInt = IsInt,
		Vue.prototype.$IsPostcard = IsPostcard
	}
}